home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TPREAL2.ARJ / TPREAL1.DOC < prev   
Text File  |  1992-03-13  |  4KB  |  71 lines

  1. Improved Floating Point Subroutines for Turbo Pascal
  2.  
  3. This software package is meant to be a superior alternative for Turbo
  4. Pascal's built in floating point library for the "real" format. Programs
  5. using the "real" format for intensive numeric computation can benefit
  6. from this package when run on a computer without a numeric co-processor.
  7. To use this package, you should have Turbo Pascal version 4.0 or later.
  8. The library is in the form of a TPU file. To use this library, you need
  9. to add the statement "uses rlib;" at the beginning of your program. The
  10. library consists of subroutines for floating point multiplication,
  11. division, sqrt, sin, cos, arctan, exp and ln. To get the equivalent of
  12. x*y in your program, just substitute _mul(x,y). Similarly, to get x/y,
  13. use _div(x,y).(x and y can themselves be expressions instead of
  14. variables.) To get the other functions, just add an underscore before
  15. the equivalent TP definition. For example, _sin(x) for sin(x).
  16.  
  17. Creating RLIB.TPU
  18.  
  19. Since TPU files created using different versions of Turbo Pascal are,
  20. in general, incompatible with one another, the TPU file has to be
  21. compiled using your current version of Turbo Pascal. To create RLIB.TPU,
  22. compile RLIB.PAS to disk, making sure that the correct path to the OBJ
  23. files which come in this package is specified in the compiler. This
  24. package also comes with a program 'TEST.PAS' which can be used to compare
  25. this package with Turbo Pascal's. The average speed improvement ranges from
  26. 20% for multiplication to about 1200% for sqrt. The "Savage" option is
  27. a benchmark to test the accuracy of the routines. The lower the residual
  28. error, the better is the accuracy of the routines. This package can be
  29. seen to be superior than Turbo Pascal's by running the "Savage" option.
  30.  
  31. Error Handling
  32.  
  33. When a floating point error occurs, the type of error and the address
  34. where the error occured in the main program are displayed and the
  35. program is halted. Errors are of three types-division by zero, overflow,
  36. and illegal function call. If you want, you can write your own error
  37. handling routine. The rules are:
  38. 1. The global pointer variable matherrptr declared in RLIB.TPU should
  39. be set to the address of your routine at the beginning of the program.
  40. Eg., matherrptr:=@myerrproc;
  41. 2. The error handling routine should be compiled with the far option
  42. turned on.({$F+})
  43. 3. The input parameters to the error handling routine are an integer
  44. and a pointer in that order. The integer contains the type of floating
  45. point error (1-division by zero, 2-overflow, 3-illegal function call)
  46. and the pointer contains the address of the main program from where the
  47. call was made. Even if you don't use these parameters, they should appear
  48. in the procedure declaration. Also, do not use "var" in the input
  49. declaration. A typical error handling routine might look like:
  50. procedure myerrproc(typeoferror:integer;erroraddr:pointer);
  51. begin
  52.     writeln('Its debugging time!');
  53. end;
  54. Failure to follow the above rules might result in a crashed program!
  55. The error handler can pass control back instead of halting. In that case,
  56. the value returned by the floating point subroutine would be 1.7E38 in
  57. magnitude, the sign depending on the input variables to the routine.
  58.  
  59. Information and Correspondence
  60.  
  61. The author hopes that this package would be useful to many. Any
  62. suggestions and questions regarding this package are welcome. Please
  63. e-mail your comments to shankar@ecn.purdue.edu. If you find this software
  64. highly useful, please send a check for any amount you wish payable to:
  65.      Shankar Ramakrishnan
  66.      253 Sheetz St. #9
  67.      West Lafayette,IN 47906
  68.  
  69. Shankar Ramakrishnan
  70. March 5 1992
  71.